<?PHP
class productEntity
{
	public static function GetRow($pid)
	{
		$product = $_ENV['db']->fetch("SELECT * FROM `product` WHERE `product_id` = '{$pid}'");
        if (!$product) $this->showMessage('找不到指定商品信息',-404);
		return $product;
	}
	/*[判断商品是否存在]*/
	public static function IsExists($pid)
	{	
		 $row = $_ENV['db']->fetchCol("SELECT name FROM `product` WHERE `product_id` = '{$pid}'");
		 if ($row) 
		 {return true;}
		 else
		 {return false;}
	}
	
	
	/*[判断商品是否存在]*/
	public static function IsExistName($name)
	{	
		 $row = $_ENV['db']->fetchCol("SELECT name FROM `product` WHERE `name` = '{$name}'");
		 if ($row) 
		 {return true;}
		 else
		 {return false;}
	}
	
	public static function GetListByIDs($pids)
	{
		return $_ENV['db']->fetchAll("SELECT * FROM `product` WHERE `product_id` IN ({$pids})");
	}
	
	
	public static function GetIDByCode($code)
	{
		$code = substr($code,0,4);
		$row = $_ENV['db']->fetchCol("SELECT class_id FROM `product_class` WHERE `code` = '{$code}'");
		return $row;
	}
}
?>